VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5235
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   12540
   LinkTopic       =   "Form1"
   ScaleHeight     =   5235
   ScaleWidth      =   12540
   StartUpPosition =   3  'Windows Default
   Begin MSCommLib.MSComm MSComm1 
      Left            =   7920
      Top             =   1440
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   9000
      TabIndex        =   2
      Top             =   480
      Width           =   1815
   End
   Begin MSComctlLib.ListView ListView2 
      Height          =   975
      Left            =   5880
      TabIndex        =   1
      Top             =   3600
      Width           =   5775
      _ExtentX        =   10186
      _ExtentY        =   1720
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "thietbi1"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "thietbi2"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "thietbi3"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "thietbi4"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.Timer Timer2 
      Left            =   7800
      Top             =   480
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   975
      Left            =   120
      TabIndex        =   0
      Top             =   3600
      Width           =   5415
      _ExtentX        =   9551
      _ExtentY        =   1720
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   4
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "current1"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "current2"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "current3"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   3
         Text            =   "current4"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.Timer Timer1 
      Left            =   600
      Top             =   360
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Dim strsql As String
Dim strsql1 As String
Dim var As Double
Dim chuoinhan As String
Private Sub Form_Load()
MSComm1.Settings = "9600,N,8,1"
MSComm1.CommPort = 5
MSComm1.RThreshold = 5
MSComm1.InputLen = 5
MSComm1.InBufferSize = 5
MSComm1.OutBufferSize = 1
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
MSComm1.PortOpen = True

Timer1.Interval = 800
Timer1.Enabled = True
Timer2.Interval = 500
Timer2.Enabled = True

End Sub

Private Sub MSComm1_OnComm()
If (MSComm1.CommEvent = comEvReceive) Then
Timer1.Enabled = True
chuoinhan = MSComm1.Input
var = Val(chuoinhan)
End If
End Sub

Private Sub Timer1_Timer()
'var = var + 1
strsql = " update current set current1=" & "'" & var & "'" & ""
Set rs = cn.Execute(strsql)
Set rs = Nothing
Me.filllistview
End Sub
Sub filllistview()
strsql = "select * from current"
Set rs = cn.Execute(strsql)
ListView1.ListItems.Clear
Do While Not rs.EOF
Set Item = ListView1.ListItems.Add(, , rs!current1)
Item.SubItems(1) = rs!current2 & ""
Item.SubItems(2) = rs!current3 & ""
Item.SubItems(3) = rs!current4 & ""
rs.MoveNext
Loop
Set rs = Nothing
End Sub
Sub filllistview2()
strsql1 = "select * from thietbi"
Set rs1 = cn.Execute(strsql1)
ListView2.ListItems.Clear
Do While Not rs1.EOF
Set Item = ListView2.ListItems.Add(, , rs1!thietbi1)
Item.SubItems(1) = rs1!thietbi2 & ""
Item.SubItems(2) = rs1!thietbi3 & ""
Item.SubItems(3) = rs1!thietbi4 & ""
rs1.MoveNext
Loop
Set rs1 = Nothing
End Sub
Private Sub Timer2_Timer()
strsql1 = "select * from thietbi"
Set rs1 = cn.Execute(strsql1)
Text1.Text = rs1("thietbi1").Value
MSComm1.Output = Text1.Text
Set rs = Nothing
Me.filllistview2

End Sub
'finish kakakaka

